var dirVector = new Array();
for (var i = 0; i < 6; i++) {
    dirVector[i] = new Array();
    for (var j = 0; j < 2; j++) {
        dirVector[i][j] = 0;
    }
}
//偶行方向向量
dirVector[0][0] = cc.p(0,1);
dirVector[1][0] = cc.p(0,-1);
dirVector[2][0] = cc.p(1,0);
dirVector[3][0] = cc.p(-1,0);
dirVector[4][0] = cc.p(1,-1);
dirVector[5][0] = cc.p(-1,-1);

//奇行方向向量
dirVector[0][1] = cc.p(0,1);
dirVector[1][1] = cc.p(0,-1);
dirVector[2][1] = cc.p(1,0);
dirVector[3][1] = cc.p(-1,0);
dirVector[4][1] = cc.p(1,1);
dirVector[5][1] = cc.p(-1,1);

var getNextByBFS = function(startPos , blockArray){
    var path = new Array();
    for (var i = 0; i < ROW; i++) {
        path[i] = new Array();
        for (var j = 0; j < COL; j++) {
            path[i][j] = cc.p(0,0);
        }
    }

    var used = new Array();
    for (var i = 0; i < ROW; i++) {
        used[i] = new Array();
        for (var j = 0; j < COL; j++) {
            used[i][j] = blockArray[i][j];
        }
    }

    var queue = new Array();
    queue.push(startPos);
    while(queue.length != 0){
        var midPos = queue.shift();

        if (midPos.x == 0
            || midPos.x == ROW - 1
            || midPos.y == 0
            || midPos.y == COL - 1) {
            return path[midPos.x][midPos.y];
        }

        var isOdd = midPos.x % 2;
        var i = Math.floor(cc.random0To1() * 6);
        i = i%6;
        for(var index = 0;index < 6;index++){
            var x = midPos.x + dirVector[i][isOdd].x;
            var y = midPos.y + dirVector[i][isOdd].y;
            if(used[x][y] == false){
                used[x][y] = true;
                queue.push(cc.p(x,y));
                var prePath = path[midPos.x][midPos.y];
                if(prePath.x == 0 && prePath.y == 0){
                    path[x][y] = dirVector[i][isOdd];
                } else{
                    path[x][y] = prePath;
                }
            }
            i++;
            i = i % 6;
        }
    }
    return false;
}